package futer;

import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @Package futer
 * @Description
 * @Author kunshan
 * @Date 2020/11/9 2:40 下午
 */
@SpringBootTest
@Log4j2
public class futerText {
    @Test
    void contextLoads() {
    }
    @Test
    public void getFuterText() throws InterruptedException, ExecutionException {
        ExecutorService service = Executors.newSingleThreadExecutor();
        Future<Integer>  future =  service.submit(()->{
            try {
                Thread.sleep(1);
            }
            catch (Exception e){ log.error(e.toString());}
            return 1;
        });

        Integer result  =  future.get();

        System.out.println(result);
    }
}
